Problem with logging

Hey,

When i run a script that processes some modules in the database and updates some object attribute values in some of them i get incomplete logs at the end of the script.

the script looks like this:

#include <xx.inc>
 
string configFilename = "D:\\...\\TRS_Config.csv"
string logFilename    = "D:\\...\\dailyUpdate.log"
Stream configFile     = read  (configFilename)
Stream logfile        = append(logFilename)
 
.
.
.
 
 
//*****************************************************************************************************************************
void processModule(string moduleName) {
 
 
    m = edit(moduleName, false)
        logfile << dateAndTime(today) " now processing module '" moduleName "'\n"
                
        Object o
        for o in entire m do {                
                // check and update object attribute values here..
        }//end for object in entire module
                
        close(m)
 
}
//*****************************************************************************************************************************
//*****************************************************************************************************************************
for (configFile >> targetFolder; ! end configFile; configFile >> targetFolder)
{
        if (!folder(targetFolder)) {
                errorBox "Target  '" targetFolder "'  is not a Folder!\nPlease check Config-File"
                halt
        }
 
        Folder f = folder targetFolder
        
        Item i
        for i in f do if(type(i) == "Formal") processModule (fullName(i))
 
}// end read config
//*****************************************************************************************************************************
 
closeAllModules()
 
//print "done!"

 


When i open the logfile after running the script i get 99% percent of the logs, but the last lines look like this:

.
.
.
04/08/10 09:19:48 now processing module '/xx/04_xx/m1'
04/08/10 09:19:49 now processing module '/xx/04_xx/m2'
04/08/10 09:19:49 now processing module '/xx/04_xx/m3'
04/08/10 09:19:50 now processing

It seems like the script halted (without any error!) before the logs were written completely. Any ideas?

Thanks in advance,
Regards,
Manuel

 


ManuelFelger - Thu Apr 08 04:20:08 EDT 2010

Re: Problem with logging
Mathias Mamsch - Thu Apr 08 04:24:00 EDT 2010

Use the void flush(Stream s) perm to make all buffered changes go to disk. Don't forget to close your stream. Regards, Mathias